package com.lxk.oms.order.api;

import com.lxk.oms.flow.supplement.PaySupplementContext;
import com.lxk.oms.order.domain.req.SupplementReq;
import com.lxk.oms.order.manger.OrderManger;
import com.lxk.service.oms.api.OrderSupplementServiceApi;
import com.lxk.service.oms.param.SupplementParam;
import com.lxk.service.oms.response.PaySupplementResult;
import lombok.AllArgsConstructor;
import org.dromara.common.core.utils.ValidationUtils;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.springframework.stereotype.Service;

/**
 * 补单 ServiceApi 实现类
 *
 * @author huahua
 */
@Service
@AllArgsConstructor
public class OrderSupplementServiceApiImpl implements OrderSupplementServiceApi {

    private final OrderManger orderManger;

    /**
     * 补单
     *
     * @param param
     * @return
     */
    @Override
    public PaySupplementResult supplement(SupplementParam param) {
        ValidationUtils.validate(param);
        SupplementReq req = new SupplementReq();
        PageQuery pageQuery = new PageQuery();
        pageQuery.setPageSize(30);
        pageQuery.setPageNum(1);
        req.setPageQuery(pageQuery);
        req.setList(param.getList());
        PaySupplementContext.SupplementResult supplement = orderManger.paySupplement(req);
        PaySupplementResult result = new PaySupplementResult();
        result.setCurrent(supplement.getCurrent());
        result.setMsg(supplement.getMsg());
        result.setSize(supplement.getSize());
        result.setSuccess(supplement.getSuccess());
        result.setHasNext(supplement.getHasNext());
        result.setTotal(supplement.getTotal());
        return result;
    }
}
